/*
 * @Author: YeMiao 
 * @Date: 2018-02-20 11:52:00 
 * @Last Modified by: YeMiao
 * @Last Modified time: 2018-03-15 11:23:49
 */
import { Component } from '@angular/core';
import { Router } from '@angular/router';
import { LoginService } from '../login.service';
import { NzNotificationService } from 'ng-zorro-antd';

@Component({
  selector: 'app-main',
  templateUrl: './main.component.html',
  styleUrls: ['./main.component.scss']
})

export class MainComponent {
  userName: String = sessionStorage.getItem('name')?sessionStorage.getItem('name'):sessionStorage.getItem('user');
  isCollapsed = false;
  isHide = true;

  constructor( 
    private router: Router,
    private _loginService: LoginService,
    private _notification: NzNotificationService
  ) {}

  ngOnInit() {
  }

  logout() {
    sessionStorage.clear();
    this._loginService.logout().subscribe(data =>{
      if(data['code'] == 1){
        this.router.navigate(['login']);
        this._notification.blank('退出成功', `时间: ${new Date().toLocaleString()}`);
      }
    });
  }

  shouUser(sign: number) {
    if(sign == 1){
      this.isHide = false;
    }else{
      this.isHide = true;
    }
  }

}